package com.ruge.common.config;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 创建人 ：爱丽丝、如歌
 * 创建时间 ：2019-11-30  21:16
 * 描述 ：swagger2 配置类
 * @author dell
 */
@EnableSwagger2
@SpringBootConfiguration
public class Swagger2Config {
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("如歌小组")
                .select()
                //RequestHandlerSelectors 配置要扫描接口的方式
               //.apis(RequestHandlerSelectors.basePackage("com.ruge"))
                .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("如歌的Swagger2 API文档")
                .version("1.0")
                .termsOfServiceUrl("127.0.0.1/")
                .contact(new Contact("爱丽丝、如歌","http:www.ruge.com","13298899809@163.com"))
                .description("谁在悬崖沏一壶茶")
                .license("ruge 1.o")
                .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
                .build();
    }

}
